package terminal.ui;

import java.awt.Color;
import java.awt.Dimension;
import java.util.ArrayList;
import javax.swing.JPanel;
import terminal.utility.Field;

public class Quote extends JPanel {

    public Quote(ArrayList<Field> fieldList) {
        setBackground(new Color(255, 255, 230));
        setLayout(null);

        createPanel(fieldList);
    }

    private void createPanel(ArrayList<Field> fieldList) {
        int columns = fieldList.size() / 10;
        double colCheck = fieldList.size() / 10.0;
        if (colCheck > columns) {
            columns += 1;
        }

        setPreferredSize(new Dimension(columns * 210, 300));

        for (int i = 0, x = 2, count = 0; i < columns; i++, x += 210) {
            for (int j = 0, y = 2; j < 10; j++, y += 30) {
                if (count < fieldList.size()) {
                    
                    Field field = fieldList.get(count);
                    field.setBounds(x, y, 200, 25);
                    add(field);
                    count++;
                }
            }
        }

    }
    
}
